﻿function isFriend(friendName, friends) {
    for (var i = 0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend.UserName == friendName)
            return true;
    }

    return false;
}

function getFriendByName(friendName, friends) {
    for (var i = 0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend.UserName == friendName)
            return friend;
    }

    return null;
}

function getFriendName(id, friendList) {
    for (var i = 0; i < friendList.length; i++) {
        var friend = friendList[i];
        if (friend.id == id)
            return friend.name;
    }

    return 'NoName';
}

function getFriend(id, friends) {
    for (var i = 0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend.Id == id)
            return friend;
    }

    return null;
}